package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.home.authorization;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.home.registered.UserInfoTabOpenerListener;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.util.Randomizer;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.InfoManager;

import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;

/**
 * @author Renato Miceli
 */
public class UnauthorizedUserInfoViewerToolbar extends Toolbar {

	private final UserInfoTabOpenerListener tabOpener;

	private final AuthorizationListener authListener;

	public UnauthorizedUserInfoViewerToolbar(InfoManager<UserInfo> infoManager, Randomizer randomizer, TabPanel centerPanel) {

		this.tabOpener = new UserInfoTabOpenerListener(centerPanel, infoManager);
		this.authListener = new AuthorizationListener(randomizer, infoManager);

		this.addButton(new ToolbarButton("Details", tabOpener));
		this.addSeparator();
		this.addButton(new ToolbarButton("Authorize", authListener));
		this.addFill();
	}

	public void updateInfo(UserInfo info) {
		this.authListener.setUserInfo(info);
		this.tabOpener.updateInfo(info);
	}

}
